
from itertools import product


class Solution:
    def twoSum(self, nums, target: int):
        nums_idx = [(item, idx) for idx, item in enumerate(nums)]
        nums_idx.sort(key=lambda x: x[0])
        n = len(nums)
        for i, j in product(range(n), range(n)):
            if (nums_idx[i][0] + nums_idx[j][0] == target) and (nums_idx[i][1] != nums_idx[j][1]):
                return [nums_idx[i][1], nums_idx[j][1]]


nums = [2, 11, 7, 15]
target = 9
print(Solution().twoSum(nums, target))
